/*
    www.cguage.com
    1.2 求数组1比数组2大的个数总和
*/

#include <iostream>
#include <sstream>
#include <cassert>
#include <vector>
using namespace std;

#ifndef TEST
#define IN(iss) {                       \
        std::string str;                \
        std::getline(std::cin, str);    \
        iss.str(str);                   \
    }
#define OUT(s) std::cout << s
#endif

#define READ_N(iss, n) {    \
    iss >> n;               \
    iss.ignore(1, ',');     \
}

int main() {
    istringstream iss;
    IN(iss);
    assert(!iss.eof());

    // 解析到两个数组(空格分隔)
    string tmp;
    istringstream issArr[2];
    vector<int> v[2];
    int n = 0;
    for (int i = 0; i < 2; ++i) {
        iss >> tmp;
        issArr[i].str(tmp);
        while (!issArr[i].eof()) {
            READ_N(issArr[i], n);
            v[i].push_back(n);
        }
    }

    // 规律是个数只会越来越多
    int num = 0;
    int total = 0;
    for (int i = 0; i < (int)v[0].size(); ++i) {
        while (num < (int)v[1].size() && v[0][i] > v[1][num]) {
            ++num;
        }
        total += num;
    }

    // 结果
    ostringstream oss;
    oss << total;
    OUT(oss.str());
    return 0;
}

#ifdef TEST
struct TestCase CASES[] = {
    /*0*/{"1,3,5,7,9 2,3,4,7,8", "12"},
    /*1*/{"1,2,3,4,5 999", "0"},
    /*2*/{"2,7,9 0", "3"}
};
#endif